package com.my.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.my.R;

import java.util.List;
import java.util.Map;

public class IconTextAdapter extends ArrayAdapter<IconTextAdapter.IconText> {

    private int resourceId;

    public IconTextAdapter(@NonNull Context context, int resource, @NonNull List<IconText> objects) {
        super(context, resource, objects);
        resourceId = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        IconText item = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId, null);
        ((ImageView) view.findViewById(R.id.icon)).setImageResource(item.icon);
        ((TextView) view.findViewById(R.id.text)).setText(item.text);
        return view;
    }

    public static class IconText {
        public int icon;
        public String text;
        public String tag;
        public boolean vis;

        IconText() {}

        public IconText(int i, String t, String tag) {
            this.icon = i;
            this.text = t;
            this.tag = tag;
            this.vis = true;
        }

        public IconText(int i, String t, String tag, boolean vis) {
            this.icon = i;
            this.text = t;
            this.tag = tag;
            this.vis = vis;
        }
    }
}
